package com.macro.mall.tiny.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
  * @className: MinioConfig
  * @author ffy
  * @date 2021/7/6 9:43
  * @description: MinioConfig
  */

@Data
@Component
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {

    private String endpoint;    // endPoint是一个URL，域名，IPv4或者IPv6地址
    private int port;           // 端口号
    private String accessKey;   // 类似于用户ID，用于唯一标识你的账户
    private String secretKey;   // 账户的密码
    private Boolean secure;     // 如果是true，则用的是https而不是http,默认值是true
    private String bucketName;  // 默认存储桶
    private String configDir;   // 配置目录

    @Bean
    public MinioClient getMinioClient() throws InvalidEndpointException, InvalidPortException {
        MinioClient minioClient = new MinioClient(endpoint, port, accessKey, secretKey, secure);
        return minioClient;
    }
}